shared_examples_for 'Msf::DBManager::ExploitAttempt' do
  it { is_expected.to respond_to :report_exploit }
  it { is_expected.to respond_to :report_exploit_attempt }
  it { is_expected.to respond_to :report_exploit_failure }
  it { is_expected.to respond_to :report_exploit_success }

  describe '#report_exploit_success' do
    subject(:report_exploit_success) do
      db_manager.report_exploit_success(opts)
    end

    let(:workspace) do
      FactoryGirl.create(:mdm_workspace)
    end

    let(:host) do
      FactoryGirl.create(:mdm_host, workspace: workspace)
    end

    let(:refs) do
      [ FactoryGirl.create(:mdm_ref) ]
    end

    let(:vuln) do
      FactoryGirl.create(:mdm_vuln)
    end

    let(:opts) do
      {
        workspace: workspace,
        refs: refs,
        host: host,
        vuln: vuln,
      }
    end

    context 'with a vuln' do
      specify do
        expect {
          report_exploit_success
        }.to change(Mdm::VulnAttempt,:count).by(1)
      end
    end

    context 'without a vuln' do
      let(:vuln) { nil }

      specify do
        expect {
          report_exploit_success
        }.not_to change(Mdm::VulnAttempt, :count)
      end
    end

  end
end
